<template>
	<view class="news">
	<news-item :list='newList' @itemClick='goDetail'></news-item>
	</view>
</template>

<script>
	import newsTtem from "../components/news-item/news-item.vue"
	export default {
		data() {
			return {
				newList:[]	/* 资讯列表 */
			}
		},
		methods: {
			async getNewList(){
				const res = await this.$myRequest({
					url:'/api/getnewslist'
				})
				this.newList = res.data.message
			},
			/* 跳转到相应的资讯页面 */
			goDetail(id){
				console.log(id)
				uni.navigateTo({
					url:'../news-detail/news-detail?id='+id
				})
			}
		},
		components:{"news-item":newsTtem},
		onLoad() {
			this.getNewList()
		}
		
	}
</script>

<style lang="scss">
	.news{
		
	}
</style>
